/*
 * @Author: ChunLai
 * @Date: 2022-03-28 17:15:21
 * @LastEditTime: 2025-11-21 09:21:04
 * @Description:
 * @FilePath: \01.latest-short-insure\src\utils\functions.js
 */
import request from "@/utils/request";
import { getProParams } from "@/methods/cache.js";

const apiPreName = "/ms-insure/api/common";

/**保费试算 */
export const apiGetRate = (data) => {
  const gys = getProParams("gys");
  if (gys == "ansheng") {
    return request.post(`ms-insure/app/ansheng/pre/premiumQuotation`, data, {
      transJson: true,
    });
  }
  return request.post(`/ms-planbook/planBook/apiGetRate`, data, { json: true });
};

/**核保接口 */
export const underwrite = (data) => {
  return request.post(`${apiPreName}/underwrite`, data, { json: true });
};

/**支付接口 */
export const payment = (data) => {
  return request.post(`${apiPreName}/pay`, data, { json: true });
};

/**验证验证码*/
export const checkShortMsg = (data) => {
  return request.post(`${apiPreName}/checkShortMsg`, data, {
    json: true,
  });
};

/**保单状态查询*/
export const orderStatus = (data) => {
  return request.post(`${apiPreName}/orderStatus`, data, {
    json: true,
  });
};

/**获取智能核保连接*/
export const getHealthNoticeUrl = (data) => {
  return request.post(`${apiPreName}/getHealthNoticeUrl`, data, {
    json: true,
  });
};

/**获取银行列表*/
export const getBankCardInfos = (data) => {
  return request.post(`${apiPreName}/getBankList`, data, {
    json: true,
  });
};

/**平安保存uuid*/
export const saveUUID = (data) => {
  return request.post(`${apiPreName}/apipingan/saveUUID`, data, {
    json: true,
  });
};

/**
 * @Author: ChunLai
 * @Date: 2022-07-22 18:10:38
 * @description: 判空
 * @param {*} data
 * @return {*}
 */
export const isEmptyEle = (data) => {
  let valType = Object.prototype.toString.call(data).slice(8, -1).toLowerCase();
  // console.log(valType)
  if (valType === "object") {
    return JSON.stringify(data) === "{}";
  } else if (valType === "array") {
    return data.length === 0;
  } else if (valType === "string") {
    return data === "";
  }
};

export const delNull = (obj) => {
  for (const key in obj) {
    if (!obj[key]) {
      delete obj[key];
    }
  }
  return obj;
};
